
Ext.define('AM.controller.Users',{

    extend:'Ext.app.Controller',
    views: ['user.List','user.Edit'],
    stores:['Users'],
    models:['User'],
    init:function () {

        //Ext.Msg.alert("提示","AM.controller.Users!");
        //control 寻找控制器里面的组建，找到对应的组建绑定事件
        this.control({
            'userlist':{itemdblclick:this.editUser},
            'useredit button[action=save]':{
                click:this.updateUser
            }
        });


    },

    editUser:function(grid,record) {
        var view = Ext.widget('useredit');
        view.down('form').loadRecord(record);
    },

    updateUser:function (button) {
        // console.log('clicked the Save button....');
        var win = button.up('window');
        form = win.down('form');

        record = form.getRecord();
        values = form.getValues();
        record.set(values);

        win.close();
        this.getUsersStore().sync();
        console.log("the record in the grid has been updated.");
    }

});